<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="订单号" prop="orderNo">
        <el-input
          v-model="queryParams.orderNo"
          placeholder="请输入订单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择订单状态" clearable>
          <el-option
            v-for="dict in dict.type.rental_order_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="支付状态" prop="paymentStatus">
        <el-select v-model="queryParams.paymentStatus" placeholder="请选择支付状态" clearable>
          <el-option
            v-for="dict in dict.type.rental_payment_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="租赁日期" prop="startDate">
        <el-date-picker clearable
          v-model="queryParams.startDate"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:orders:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:orders:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:orders:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:orders:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 横向列表展示 -->
    <div v-loading="loading" class="orders-list-container">
      <div 
        v-for="order in ordersList" 
        :key="order.orderId" 
        class="order-card"
        :class="{ 'selected': selectedOrders.includes(order.orderId) }"
      >
        <!-- 选择框和ID -->
        <div class="order-header">
          <div class="order-selection">
            <el-checkbox 
              v-model="order.selected" 
              @change="handleOrderSelection(order)"
            ></el-checkbox>
            <span class="order-id">ID: {{ order.orderId }}</span>
          </div>
        </div>

        <!-- 订单基本信息 -->
        <div class="order-content">
          <div class="order-main-info">
            <div class="order-number">
              <span class="label">订单号：</span>
              <span class="value highlight">{{ order.orderNo }}</span>
            </div>
            <div class="order-status">
              <dict-tag :options="dict.type.rental_order_status" :value="order.status"/>
            </div>
          </div>

          <!-- 详细信息网格 -->
          <div class="order-details">
            <div class="detail-row">
              <div class="detail-item">
                <span class="label">租客ID：</span>
                <span class="value">{{ order.userId }}</span>
              </div>
              <div class="detail-item">
                <span class="label">设备ID：</span>
                <span class="value">{{ order.deviceId }}</span>
              </div>
              <div class="detail-item">
                <span class="label">租赁天数：</span>
                <span class="value">{{ order.rentDays }}天</span>
              </div>
            </div>

            <div class="detail-row">
              <div class="detail-item">
                <span class="label">开始日期：</span>
                <span class="value">{{ parseTime(order.startDate, '{y}-{m}-{d}') }}</span>
              </div>
              <div class="detail-item">
                <span class="label">结束日期：</span>
                <span class="value">{{ parseTime(order.endDate, '{y}-{m}-{d}') }}</span>
              </div>
              <div class="detail-item" v-if="order.actualReturnDate">
                <span class="label">实际归还：</span>
                <span class="value">{{ parseTime(order.actualReturnDate, '{y}-{m}-{d}') }}</span>
              </div>
              <div class="detail-item">
                <span class="label">创建时间：</span>
                <span class="value">{{ parseTime(order.createdTime, '{y}-{m}-{d}') }}</span>
              </div>
            </div>

            <div class="detail-row">
              <div class="detail-item">
                <span class="label">日租金：</span>
                <span class="value price">¥{{ order.dailyRent }}</span>
              </div>
              <div class="detail-item">
                <span class="label">总租金：</span>
                <span class="value price">¥{{ order.totalRent }}</span>
              </div>
              <div class="detail-item">
                <span class="label">押金：</span>
                <span class="value price">¥{{ order.deposit }}</span>
              </div>
              <div class="detail-item">
                <span class="label">总金额：</span>
                <span class="value price highlight">¥{{ order.totalAmount }}</span>
              </div>
            </div>

            <div class="detail-row">
              <div class="detail-item full-width">
                <span class="label">交付方式：</span>
                <dict-tag :options="dict.type.rental_delivery_type" :value="order.deliveryType"/>
                <span v-if="order.deliveryType === 1 && order.pickupAddress" class="delivery-info">
                  （自提地址：{{ order.pickupAddress }}）
                </span>
                <span v-if="order.deliveryType === 2 && order.deliveryAddressId" class="delivery-info">
                  （配送地址ID：{{ order.deliveryAddressId }}）
                </span>
              </div>
            </div>

            <div class="detail-row" v-if="order.remark || order.cancelReason">
              <div class="detail-item full-width" v-if="order.remark">
                <span class="label">备注：</span>
                <span class="value">{{ order.remark }}</span>
              </div>
              <div class="detail-item full-width" v-if="order.cancelReason">
                <span class="label">取消原因：</span>
                <span class="value cancel-reason">{{ order.cancelReason }}</span>
              </div>
            </div>
          </div>
        </div>
        
        <!-- 操作按钮区域 - 右下角 -->
        <div class="order-actions-bottom">
          <el-button
            size="mini"
            type="primary"
            icon="el-icon-edit"
            @click="handleUpdate(order)"
            v-hasPermi="['system:orders:edit']"
            plain
          >修改</el-button>
          <el-button
            size="mini"
            type="danger"
            icon="el-icon-delete"
            @click="handleDelete(order)"
            v-hasPermi="['system:orders:remove']"
            plain
          >删除</el-button>
        </div>
      </div>

      <!-- 空状态 -->
      <div v-if="ordersList.length === 0" class="empty-state">
        <el-empty description="暂无订单数据"></el-empty>
      </div>
    </div>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改租赁订单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="订单号" prop="orderNo">
              <el-input v-model="form.orderNo" placeholder="请输入订单号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="租客用户ID" prop="userId">
              <el-input v-model="form.userId" placeholder="请输入租客用户ID" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备ID" prop="deviceId">
              <el-input v-model="form.deviceId" placeholder="请输入设备ID" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="租赁开始日期" prop="startDate">
              <el-date-picker clearable style="width: 100%"
                v-model="form.startDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择租赁开始日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="租赁结束日期" prop="endDate">
              <el-date-picker clearable style="width: 100%"
                v-model="form.endDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择租赁结束日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际归还日期" prop="actualReturnDate">
              <el-date-picker clearable style="width: 100%"
                v-model="form.actualReturnDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择实际归还日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="租赁天数" prop="rentDays">
              <el-input v-model="form.rentDays" placeholder="请输入租赁天数" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="日租金" prop="dailyRent">
              <el-input v-model="form.dailyRent" placeholder="请输入日租金" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总租金" prop="totalRent">
              <el-input v-model="form.totalRent" placeholder="请输入总租金" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="押金" prop="deposit">
              <el-input v-model="form.deposit" placeholder="请输入押金" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单总金额" prop="totalAmount">
              <el-input v-model="form.totalAmount" placeholder="请输入订单总金额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单状态：1-待支付，2-已支付，3-进行中，4-已完成，5-已取消，6-已退款">
              <el-radio-group v-model="form.status">
                <el-radio
                  v-for="dict in dict.type.rental_order_status"
                  :key="dict.value"
:label="parseInt(dict.value)"                >{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="支付状态：0-未支付，1-已支付，2-部分退款，3-全额退款">
              <el-radio-group v-model="form.paymentStatus">
                <el-radio
                  v-for="dict in dict.type.rental_payment_status"
                  :key="dict.value"
:label="parseInt(dict.value)"                >{{dict.label}}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="配送地址ID" prop="deliveryAddressId">
              <el-input v-model="form.deliveryAddressId" placeholder="请输入配送地址ID" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="自提地址" prop="pickupAddress">
              <el-input v-model="form.pickupAddress" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="订单备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="取消原因" prop="cancelReason">
              <el-input v-model="form.cancelReason" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="创建时间" prop="createdTime">
              <el-date-picker clearable style="width: 100%"
                v-model="form.createdTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择创建时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="更新时间" prop="updatedTime">
              <el-date-picker clearable style="width: 100%"
                v-model="form.updatedTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择更新时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listOrders, getOrders, delOrders, addOrders, updateOrders } from "@/api/system/orders";

export default {
  name: "Orders",
  dicts: ['rental_order_status', 'rental_payment_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 租赁订单表格数据
      ordersList: [],
      // 选中的订单列表
      selectedOrders: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNo: null,
        userId: null,
        deviceId: null,

        startDate: null,
        endDate: null,
        actualReturnDate: null,
        rentDays: null,
        dailyRent: null,
        totalRent: null,
        deposit: null,
        totalAmount: null,
        status: null,
        paymentStatus: null,
        deliveryType: null,
        deliveryAddressId: null,
        pickupAddress: null,
        cancelReason: null,
        createdTime: null,
        updatedTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        orderNo: [
          { required: true, message: "订单号不能为空", trigger: "blur" }
        ],
        userId: [
          { required: true, message: "租客用户ID不能为空", trigger: "blur" }
        ],
        deviceId: [
          { required: true, message: "设备ID不能为空", trigger: "blur" }
        ],

        startDate: [
          { required: true, message: "租赁开始日期不能为空", trigger: "blur" }
        ],
        endDate: [
          { required: true, message: "租赁结束日期不能为空", trigger: "blur" }
        ],
        rentDays: [
          { required: true, message: "租赁天数不能为空", trigger: "blur" }
        ],
        dailyRent: [
          { required: true, message: "日租金不能为空", trigger: "blur" }
        ],
        totalRent: [
          { required: true, message: "总租金不能为空", trigger: "blur" }
        ],
        deposit: [
          { required: true, message: "押金不能为空", trigger: "blur" }
        ],
        totalAmount: [
          { required: true, message: "订单总金额不能为空", trigger: "blur" }
        ],
        status: [
          { required: true, message: "订单状态：1-待支付，2-已支付，3-进行中，4-已完成，5-已取消，6-已退款不能为空", trigger: "change" }
        ],
        paymentStatus: [
          { required: true, message: "支付状态：0-未支付，1-已支付，2-部分退款，3-全额退款不能为空", trigger: "change" }
        ],
        deliveryType: [
          { required: true, message: "交付方式：1-自提，2-配送不能为空", trigger: "change" }
        ],
        createdTime: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ],
        updatedTime: [
          { required: true, message: "更新时间不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询租赁订单列表 */
    getList() {
      this.loading = true;
      listOrders(this.queryParams).then(response => {
        this.ordersList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        orderId: null,
        orderNo: null,
        userId: null,
        deviceId: null,

        startDate: null,
        endDate: null,
        actualReturnDate: null,
        rentDays: null,
        dailyRent: null,
        totalRent: null,
        deposit: null,
        totalAmount: null,
        status: null,
        paymentStatus: null,
        deliveryType: null,
        deliveryAddressId: null,
        pickupAddress: null,
        remark: null,
        cancelReason: null,
        createdTime: null,
        updatedTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.orderId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    // 处理订单选择
    handleOrderSelection(order) {
      if (order.selected) {
        if (!this.selectedOrders.includes(order.orderId)) {
          this.selectedOrders.push(order.orderId);
        }
      } else {
        const index = this.selectedOrders.indexOf(order.orderId);
        if (index > -1) {
          this.selectedOrders.splice(index, 1);
        }
      }
      
      // 更新选中状态
      this.ids = this.selectedOrders;
      this.single = this.selectedOrders.length !== 1;
      this.multiple = this.selectedOrders.length === 0;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加租赁订单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const orderId = row.orderId || this.ids
      getOrders(orderId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改租赁订单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.orderId != null) {
            updateOrders(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrders(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const orderIds = row.orderId || this.ids;
      this.$modal.confirm('是否确认删除租赁订单编号为"' + orderIds + '"的数据项？').then(function() {
        return delOrders(orderIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/orders/export', {
        ...this.queryParams
      }, `orders_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>

<style scoped>
/* 订单列表容器 */
.orders-list-container {
  margin-top: 8px;
  background: #f5f7fa;
  padding: 16px;
  border-radius: 12px;
  min-height: 200px;
}

/* 订单卡片 - 更现代化设计 */
.order-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 12px;
  padding: 12px 16px 50px 16px; /* 下内边距增加给操作按钮留空间 */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
}

.order-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #409eff 0%, #67c23a 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.order-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.08);
  border-color: #409eff;
}

.order-card:hover::before {
  opacity: 1;
}

.order-card.selected {
  border-color: #409eff;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  box-shadow: 0 4px 20px rgba(64, 158, 255, 0.15);
}

.order-card.selected::before {
  opacity: 1;
}

/* 订单头部 - 更紧凑 */
.order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.order-selection {
  display: flex;
  align-items: center;
  gap: 6px;
}

.order-id {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

.order-actions {
  display: flex;
  gap: 4px;
}

/* 右下角操作按钮区域 */
.order-actions-bottom {
  position: absolute;
  bottom: 12px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.order-actions-bottom .el-button {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border-width: 1px;
}

.order-actions-bottom .el-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.order-actions-bottom .el-button--primary.is-plain {
  background: rgba(64, 158, 255, 0.1);
  border-color: #409eff;
  color: #409eff;
}

.order-actions-bottom .el-button--primary.is-plain:hover {
  background: #409eff;
  color: white;
}

.order-actions-bottom .el-button--danger.is-plain {
  background: rgba(245, 108, 108, 0.1);
  border-color: #f56c6c;
  color: #f56c6c;
}

.order-actions-bottom .el-button--danger.is-plain:hover {
  background: #f56c6c;
  color: white;
}

/* 订单内容 - 更紧凑 */
.order-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 订单主要信息 - 重新设计 */
.order-main-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  background: rgba(64, 158, 255, 0.04);
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 3px solid #409eff;
}

.order-number {
  display: flex;
  align-items: center;
  gap: 6px;
}

.order-number .label {
  font-size: 12px;
  color: #475569;
  font-weight: 600;
}

.order-number .value.highlight {
  font-size: 15px;
  font-weight: 700;
  color: #1e40af;
  font-family: 'Monaco', 'Menlo', monospace;
}

.order-status {
  display: flex;
  gap: 6px;
}

/* 详细信息网格 - 更紧凑 */
.order-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: center;
  padding: 4px 0;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 20px;
  padding: 2px 0;
}

.detail-item.full-width {
  grid-column: 1 / -1;
  background: rgba(248, 250, 252, 0.8);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.detail-item .label {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
  min-width: fit-content;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-item .value {
  font-size: 12px;
  color: #1e293b;
  font-weight: 500;
  word-break: break-all;
}

.detail-item .value.price {
  font-weight: 700;
  color: #dc2626;
  font-family: 'Monaco', 'Menlo', monospace;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #fecaca;
}

.detail-item .value.highlight {
  font-weight: 700;
  color: #dc2626;
  font-size: 13px;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #fca5a5;
  font-family: 'Monaco', 'Menlo', monospace;
}

.detail-item .value.cancel-reason {
  color: #dc2626;
  background: #fef2f2;
  padding: 2px 6px;
  border-radius: 4px;
  font-style: italic;
}

.delivery-info {
  font-size: 11px;
  color: #64748b;
  margin-left: 6px;
  font-style: italic;
}

/* 状态标签优化 */
.order-status .el-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 0;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 12px;
  border: 2px dashed #cbd5e1;
}

/* 响应式设计 - 优化 */
@media (max-width: 768px) {
  .order-card {
    padding: 10px 12px 45px 12px; /* 移动端也要给操作按钮留空间 */
    margin-bottom: 10px;
  }
  
  .order-actions-bottom {
    bottom: 8px;
    right: 12px;
    gap: 6px;
  }
  
  .order-actions-bottom .el-button {
    padding: 4px 8px;
    font-size: 11px;
  }
  
  .order-main-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 6px 10px;
  }
  
  .detail-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  
  .detail-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 3px 0;
  }
  
  .detail-item.full-width {
    padding: 4px 8px;
  }
}

@media (max-width: 480px) {
  .order-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  
  .order-actions {
    align-self: flex-end;
  }
  
  .order-card {
    padding: 8px 10px;
  }
}

/* 动画效果 */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.order-card {
  animation: slideInUp 0.3s ease-out;
}

/* 加载状态优化 */
.orders-list-container[v-loading] {
  min-height: 200px;
  border-radius: 12px;
}
</style>
